# mkdir build;cd build
# cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

cmake_minimum_required (VERSION 3.0)
project (cpp_leak_sample)
set(CMAKE_COLOR_MAKEFILE   ON)

IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
    add_executable(cpp_leak_sample ./src/cpp_leak_sample.cpp)
ELSE ()
    # 设置内存检查方式
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")

    add_compile_options(-g)
    add_compile_options(-fdiagnostics-color=auto)
    # 去掉函数调用时的frame pointer.
    add_compile_options(-fomit-frame-pointer)
    add_compile_options(-std=c++17)
    add_compile_options(-ggdb)
    add_compile_options(-Wall)

    add_definitions(-D_GLIBCXX_DEBUG)
    add_definitions(-DNDEBUG)

    link_libraries(stdc++fs)
    add_executable(cpp_leak_sample ./src/cpp_leak_sample.cpp)    
    target_link_libraries(cpp_leak_sample)
ENDIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
